#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int minAddToMakeValid(string str) {
    int res = 0;
    int left = 0;
    for (int i = 0; i < str.size(); i++)
    {
        if (str[i] == '(')
            left++;
        else
        {
            if (left > 0)
                left--;
            else
                res++;
        }
    }
    return res + left;
}

int addDigits(int num) {
    while (num >= 10)
    {
        int newnum = 0;
        int tmp = num;
        while (tmp)
        {
            newnum += (tmp % 10);
            tmp /= 10;
        }
        num = newnum;
    }
    return num;
}

int main()
{
    addDigits(38);
    return 0;
}